#include "BvCamera.h"

//----------------------------------------------------------------------------//
BvCamera::BvCamera() 
    : m_position(D3DXVECTOR3(0,10,-10.0f)), 
    m_lookAt(D3DXVECTOR3(0,1,0)),
    m_up(D3DXVECTOR3(0.0f, 1.0f, 0.0f)),
    m_rotation(D3DXVECTOR3(0,0,0)) 
{
    D3DXMatrixLookAtLH( &m_viewMatrix, &m_position, &m_lookAt, &m_up );
}

//----------------------------------------------------------------------------//
BvCamera::BvCamera(const D3DXVECTOR3& position, const D3DXVECTOR3& lookAt,
    const D3DXVECTOR3& up) 
    : m_position(position), 
    m_lookAt(lookAt),
    m_up(up),
    m_rotation(D3DXVECTOR3(0,0,0)) 
{
    D3DXMatrixLookAtLH( &m_viewMatrix, &m_position, &m_lookAt, &m_up );
}


//----------------------------------------------------------------------------//
BvCamera::~BvCamera()
{
}

//----------------------------------------------------------------------------//
void BvCamera::setPosition(float x, float y, float z)
{
    D3DXVECTOR3 vec3(x,y,z);
    this->setPosition(vec3);
}

//----------------------------------------------------------------------------//
void BvCamera::setPosition(const D3DXVECTOR3& vec3)
{
    m_position = vec3;
    D3DXMatrixLookAtLH( &m_viewMatrix, &m_position, &m_lookAt, &m_up );
}

//----------------------------------------------------------------------------//
void BvCamera::lookAt(float x, float y, float z)
{
    D3DXVECTOR3 vec3(x,y,z);
    this->lookAt(vec3);
}

//----------------------------------------------------------------------------//
void BvCamera::lookAt(const D3DXVECTOR3& vec3)
{
    m_lookAt = vec3;
    D3DXMatrixLookAtLH( &m_viewMatrix, &m_position, &m_lookAt, &m_up );
}

//----------------------------------------------------------------------------//
const D3DXVECTOR3& BvCamera::GetPosition() const
{
    return m_position;
}

//----------------------------------------------------------------------------//
const D3DXMATRIX& BvCamera::GetViewMatrix() const
{
    return m_viewMatrix;
}